<template>
  <view>
    <view>
      <slot name="top"></slot>
    </view>
    <view class="ss-order-card-warp ss-flex ss-row-between bg-white"
      :style="[{ borderRadius: radius + 'rpx', marginBottom: marginBottom + 'rpx' }]">
      <view class="img-box ss-m-r-24">
        <image class="order-img" :src="sheep.$url.cdn(img)" mode="aspectFill"></image>
      </view>
      <view class="box-right" :style="[{ width: titleWidth ? titleWidth + 'rpx' : '' }]">
        <view class="ss-line-2 b">{{ name }}</view>
        <view>{{ idCard }}</view>
        <view class="price-text ss-col-center" style="width:100%;">
          <view :class="sex == '男' ? 'sex-man' : 'sex-woman'">
            {{ sex }}
          </view>
          <view class="age">
            {{age}}岁
          </view>
        </view>
      </view>
      <uni-icons type="right"></uni-icons>
    </view>
  </view>
</template>

<script setup>
  import sheep from '@/sheep';
  import {
    computed
  } from 'vue';
  import {
    fen2yuan
  } from '@/sheep/hooks/useGoods';
  /**
   * 订单卡片
   *
   * @property {String} img 											- 图片
   * @property {String} title 										- 标题
   * @property {Number} titleWidth = 0								- 标题宽度，默认0，单位rpx
   * @property {String} skuText 										- 规格
   * @property {String | Number} price 								- 价格
   * @property {String} priceColor 									- 价格颜色
   * @property {Number | String} num									- 数量
   *
   */
  const props = defineProps({
    img: {
      type: String,
      default: 'https://img1.baidu.com/it/u=1601695551,235775011&fm=26&fmt=auto',
    },
    name: {
      type: String,
      default: '',
    },
    titleWidth: {
      type: Number,
      default: 0,
    },
    skuText: {
      type: [String, Array],
      default: '',
    },
    sex: {
      type: [String],
      default: '男',
    },
    priceColor: {
      type: [String],
      default: '',
    },
    age: {
      type: [String, Number],
      default: 0,
    },
    idCard: {
      type: [String],
      default: '',
    },
    point: {
      type: [String, Number],
      default: '',
    },
    radius: {
      type: [String],
      default: '',
    },
    marginBottom: {
      type: [String],
      default: '',
    },
  });
  const skuString = computed(() => {
    if (!props.skuText) {
      return '';
    }
    if (typeof props.skuText === 'object') {
      return props.skuText.join(',');
    }
    return props.skuText;
  });
</script>

<style lang="scss" scoped>
  .sex-man {
    float: left;
    width: 50rpx;
    text-align: center;
    padding: 8rpx 0;
    border-radius: 8rpx;
    color: #FFF;
    background: linear-gradient(90deg, #007aff, #37c0fe) !important;
  }

  .sex-woman {
    float: left;
    width: 50rpx;
    text-align: center;
    padding: 8rpx 0;
    border-radius: 8rpx;
    color: #FFF;
    background: linear-gradient(90deg, #ed456b, #ed81ae) !important;
  }

  .age {
    float: left;
    width: 100rpx;
    text-align: center;
    margin-left: 20rpx;
    padding: 8rpx 0rpx;
    border-radius: 8rpx;
    color: #FFF;
    background-color: #ff6000;
  }

  .right-forwrad-icon {
    position: absolute;
    right: 10rpx;
  }

  .point-img {
    width: 36rpx;
    height: 36rpx;
    margin: 0 4rpx;
  }

  .ss-order-card-warp {
    padding: 20rpx;

    .img-box {
      width: 164rpx;
      height: 164rpx;
      border-radius: 50%;
      overflow: hidden;

      .order-img {
        width: 164rpx;
        height: 164rpx;
      }
    }

    .box-right {
      flex: 1;
      // width: 500rpx;
      // height: 164rpx;
      justify-content: space-between;
      display: flex;
      flex-direction: column;
      position: relative;
      width: 164rpx;
      height: 164rpx;

      .tool-box {
        position: absolute;
        right: 0rpx;
        bottom: -10rpx;
      }
    }

    .title-text {
      font-size: 32rpx;
      font-weight: 500;
      line-height: 80rpx;
    }

    .spec-text {
      font-size: 24rpx;
      font-weight: 400;
      color: $dark-9;
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 1;
      -webkit-box-orient: vertical;
    }

    .price-text {
      font-size: 24rpx;
      font-weight: 500;
      font-family: OPPOSANS;
    }

    .total-text {
      font-size: 24rpx;
      font-weight: 400;
      line-height: 24rpx;
      color: $dark-9;
      margin-left: 8rpx;
    }

    .b {
      font-weight: bold;
    }
  }
</style>